<template>

    <div id="aduser">
        <g-admin></g-admin>
        <h1>编辑论坛</h1>
        <el-table :data="tableData" border="true" style="width: 100%">
            <el-table-column prop="forumID" label="论坛编号" width="150px"></el-table-column>
            <el-table-column prop="title" label="论坛题目" width="150px"></el-table-column>
            <el-table-column label="用户姓名" prop="userName"></el-table-column>
            <el-table-column label="内容" prop="content"></el-table-column>
            <el-table-column label="发布时间" prop="submitTime"></el-table-column>
            <el-table-column label="访问数" prop="visitNum"></el-table-column>
            <el-table-column label="推荐数" prop="recommendNum"></el-table-column>
            <el-table-column label="操作" width="180px">
                <template slot-scope="scope">
                    <!-- 编辑按钮 -->
                    <el-button >审核留言内容</el-button>
                    <el-button @click="floor(scope.row['forumID'])" type="primary" size="small">进入论坛分楼层</el-button>
                    <el-button @click="deleteArticle(scope.row['forumID'])" type="danger" size="small">删除整楼</el-button>
                    <el-button @click="edit(scope.row['userName'])" type="text" size="small">修改信誉分</el-button>

                </template>
            </el-table-column>
        </el-table>

    </div>

</template>

<script>
    import GAdmin from '../../components/gadmin/GAdmin';
    import axios from 'axios'
    export default {
        components:{
            GAdmin
        },
        data() {
            return {
                tableData:[{
                    forumId:'',
                    userName:'',
                    content:'',
                    visitNum:'',
                    recommendNum:'',
                    submitTime:'',
                    title:''
                }
                ]
            }
        },
        created() {

            this.request({
                url:'http://127.0.0.1:8080/forum/findall'
            }).then(res=>{
                this.tableData = res.data;
                console.log(this.tableData);
            }).catch(err=>{
                console.log(err);
            });

        },
        mounted(){
            document.querySelector('.tabbar').setAttribute('style','display:none');
            document.querySelector('.gfooter').setAttribute('style','display:none');
        },
        methods: {
            floor(forumId){
                this.$router.push({
                    path:'/admin/admin/adforumfloor',
                    query:{
                        forumID:forumId
                    }
                }).catch(error=>error)

            },
            deleteArticle(forumId){
                this.request({
                    url:'/forum/deleteforum/'+forumId
                }).then(res=>{
                    alert("删除整楼成功");
                }).catch(err=>{
                    console.log(err);
                });
            },
            edit(userName){
                this.$router.push({
                    path:'/admin/admin/update',
                    query:{
                        userName:userName
                    }}).catch(error=>error)
            }

        }
    }
</script>

<style scoped>

    #aduser{
        width: 90%;
        margin-left: 10%;
        margin-top: 40px;
    }
</style>